#!/bin/bash
set -x

#Disable default MySQL module
MYSQL_SOFT="{{ mysql_rpm_dir }}"
PERL_SOFT="{{ perl_dir }}"
NETTOOLS_SOFT="{{ nettools_dir }}"


sudo yum module disable mysql > /dev/null 2>&1


# Clear mariadb

if [ `sudo rpm -qa | grep mariadb | wc -l` -gt 0 ];then
    sudo rpm -qa | xargs -i rpm -e {} 
fi

# Determine whether to install net tools

if [ `sudo rpm -qa | grep net-tools | wc -l` -eq 0 ];then
    sudo dnf install $NETTOOLS_SOFT/*.rpm --skip-broken -y --disablerepo=AppStream,updates,BaseOS,Extras
fi

# Determine whether to install Perl
if [ `sudo rpm -qa | grep perl | wc -l` -eq 0 ];then
    sudo dnf install $PERL_SOFT/*.rpm --skip-broken -y --disablerepo=AppStream,updates,BaseOS,Extras
fi

# Determine whether to install MySQL
sudo which mysql > /dev/null 2>&1
if [[ `echo $?` -ne 0 ]];then
    sudo dnf install $MYSQL_SOFT/*.rpm --skip-broken -y --disablerepo=AppStream,updates,BaseOS
fi




